package org.wdcode.common.util;

import java.util.Collection;
import java.util.Map;

import org.wdcode.common.config.ConfigManage;

/**
 * 一些公用的方法类
 * @author WD
 * @since JDK6
 * @version 1.0 2009-03-01
 */
public final class CommonUtil {
	/**
	 * 判断对象是否空 判断 object == null
	 * @param object 对象
	 * @return true为空,false非空
	 */
	public final static boolean isEmpty(Object object) {
		return object == null;
	}

	/**
	 * 返回集合是否为空 判断 c == null || c.size() == 0
	 * @param c 实现Collection接口集合
	 * @return true为空,false非空
	 */
	public final static boolean isEmpty(Collection<?> c) {
		return c == null || c.size() == 0;
	}

	/**
	 * 返回Map是否为空 判断 m == null || m.size() == 0
	 * @param m 实现Map接口集合
	 * @return true为空,false非空
	 */
	public final static boolean isEmpty(Map<?, ?> m) {
		return m == null || m.size() == 0;
	}

	/**
	 * 返回字符串是否为空 判断cs == null || cs.length() == 0;
	 * @param cs CharSequence接口与子对象
	 * @return true为空,false非空
	 */
	public final static boolean isEmpty(CharSequence cs) {
		return cs == null || cs.length() == 0;
	}

	/**
	 * 判断对象数组是否空 判断 objects == null || objects.length == 0
	 * @param objects 数组对象
	 * @return true为空,false非空
	 */
	public final static boolean isEmpty(Object[] objects) {
		return objects == null || objects.length == 0;
	}

	/**
	 * 判断int数组是否空 判断 objects == null || objects.length == 0
	 * @param objects 数组对象
	 * @return true为空,false非空
	 */
	public final static boolean isEmpty(int[] objects) {
		return objects == null || objects.length == 0;
	}

	/**
	 * 判断对象是否空 判断 object == null
	 * @param object 对象
	 * @return true为空,false非空
	 */
	public final static boolean isEmpty(ConfigManage config) {
		return config == null || config.isEmpty();
	}

	/*
	 * 私有构造，禁止外部实例化
	 */
	private CommonUtil() {}
}
